import java.util.*;

public class Account {
    private static long nextId = 1;
    private long id;
    private double balance;
    private String password;


    public Account(double balance, String password) {
        this.id = nextId ++;
        this.balance = balance;
        this.password = password;
    }

    public long getId() {
        return id;
    }


    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "Account{" +
                "balance=" + balance +
                ", password='" + password + '\'' +
                '}';
    }
}

class Test{
    public static void main(String[] args) {
        List<Account> accountList = new ArrayList<>();
        accountList.add(new Account(10.00, "1234"));
        accountList.add(new Account(15.00, "5678"));
        accountList.add(new Account(0, "1010"));
        accountList.forEach( o -> System.out.println(o));

        Map<Long, Account> accountMap = new HashMap<>();
        for (Account account : accountList) {
            accountMap.put(account.getId(), account);
        }

        Set<Long> set = accountMap.keySet();
        Iterator<Long> iterator = set.iterator();
        while (iterator.hasNext()) {
            Long key = Long.valueOf(iterator.next());
            double value = accountMap.get(key).getBalance();
            System.out.println("ID: " + key +"，余额为：" + value);
        }

//        for (Map.Entry<Long, Account> entry : accountMap.entrySet()) {
//            long id = entry.getKey();
//            double balance = entry.getValue().getBalance();
//            System.out.println("ID: " + id + ", Balance: " + balance);
//        }
    }
}